﻿using Cms.Domain.RepositoryInterfaces;
using iLib.Web.Mvc;

namespace Cms.Application
{
    public abstract class BasePresenter : iLib.Web.Mvc.BaseController
    {
        private readonly IRepositoryFactory _repositoryFactory;

        public BasePresenter(IRepositoryFactory factory)
        {
            _repositoryFactory = factory;
        }

        public BasePresenter(IBaseView view, IRepositoryFactory factory)
            : base(view)
        {
            _repositoryFactory = factory;
        }

        protected IRepositoryFactory RepositoryFactory
        {
            get { return _repositoryFactory; }
        }

        protected ISiteRepository SiteRepository
        {
            get { return _repositoryFactory.SiteRepository; }
        }
        
        protected IFolderRepository FolderRepository
        {
            get { return _repositoryFactory.FolderRepository; }
        }
        
        protected IPageRepository PageRepository
        {
            get { return _repositoryFactory.PageRepository; }
        }

        protected ILocaleRepository LocaleRepository
        {
            get { return _repositoryFactory.LocaleRepository; }
        }

        protected IAdministratorRepository AdministratorRepository
        {
            get { return _repositoryFactory.AdministratorRepository; }
        }

        protected IContentRepository ContentRepository
        {
            get { return _repositoryFactory.ContentRepository; }
        }

        protected ICategoryRepository CategoryRepository
        {
            get { return _repositoryFactory.CategoryRepository; }
        }

        protected IMediaRepository MediaRepository
        {
            get { return _repositoryFactory.MediaRepository; }
        }
        
        protected ISystemRepository SystemRepository
        {
            get { return _repositoryFactory.SystemRepository; }
        }
        
        protected IUserRepository UserRepository
        {
            get { return _repositoryFactory.UserRepository; }
        }

        protected IPermissionRepository PermissionRepository
        {
            get { return _repositoryFactory.PermissionRepository; }
        }

        protected string GetText(ITranslatable view, string key)
        {
            return Translator.GetText(view.ContextTranslationFile, key, view.Localization);
        }
    }
}